package org.znxs.znxsojjudge;

import org.springframework.stereotype.Service;
import org.znxs.model.model.entity.QuestionSubmit;
import org.znxs.model.model.judge.JudgeInfo;
import org.znxs.znxsojjudge.strategy.DefaultJudgeStrategy;
import org.znxs.znxsojjudge.strategy.JavaLanguageJudgeStrategy;
import org.znxs.znxsojjudge.strategy.JudgeContext;
import org.znxs.znxsojjudge.strategy.JudgeStrategy;

/**
 * 方便调用判题
 */
@Service
public class JudgeManager {


    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
